import { api } from '@/utils'
export default function ({ $axios, store, app, route, redirect }) {
  if (route.name.indexOf('xuanke') > -1) {
    return app.$axios.get(api._isFinishTest).then(data => {
      store.commit('SET_HOLLAND_TEST', { xuankeFinish: data })
      if (route.name === 'xuanke' && data && !store.state.hollandTest.xuankeReset) {
        redirect('/xuanke/report')
      }
    }).catch(err => {
      console.log(err)
    })
  } else if (route.name.indexOf('zhiyuan') > -1) {
    return app.$axios.get(api.isFinishTest).then(data => {
      store.commit('SET_HOLLAND_TEST', { zhiyuanFinish: data })
      if (route.name === 'zhiyuan-holland-entry' && data && !store.state.hollandTest.zhiyuanReset) {
        redirect('/zhiyuan/report')
      }
    }).catch(err => {
      console.log(err)
    })
  }
}
